package com.example.administrator.androidhomework2311;

        import android.support.v7.app.AppCompatActivity;
        import android.os.Bundle;
        import android.view.View;
        import android.widget.Button;
        import android.widget.EditText;
        import android.widget.RadioGroup;
        import android.widget.TextView;
        import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
    //要用到的控件，定义对应的成员变量，以便从界面中找到并使用
    EditText mEthHeight;//身高控件
    RadioGroup mReSex;//性别控件
    Button mBtnCompute;//计算按钮控件
    TextView mTvResult;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mEthHeight = findViewById(R.id.et_height);
        mReSex = findViewById(R.id.rg_sex);
        mBtnCompute = findViewById(R.id.btn_compute);

        mBtnCompute.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String sHeight = mEthHeight.getText().toString();
                int height = Integer.parseInt(sHeight);
                int height2 = Integer.parseInt(mEthHeight.getText().toString());

                int id = mReSex.getCheckedRadioButtonId();
                if(id == R.id.rb_male){
                    int standardWeight = (int)((height - 100)* 0.9);
                    //mTvResult.setText("标准体重是:"+standardWeight+"KG");
                    Toast.makeText(MainActivity.this,
                            "标准体重是:",
                            Toast.LENGTH_SHORT).show();


                }else if (id == R.id.rb_female);
                    int standarWeight = (int)((height-100)*0.9-2.5);
                    mTvResult.setText("标准体重是:"+standarWeight+"KG");
                
            }
        });

    }
}
